package com.qingfeng.medical.controller.front.message;

import com.qingfeng.medical.base.controller.BaseController;
import com.qingfeng.medical.base.log.annotation.Log;
import com.qingfeng.medical.base.log.enums.BusinessType;
import com.qingfeng.medical.base.result.Result;
import com.qingfeng.medical.biz.information.domain.entity.UserInfo;
import com.qingfeng.medical.biz.information.domain.vo.DiseaseDoctorVo;
import com.qingfeng.medical.biz.information.service.UserInfoService;
import com.qingfeng.medical.biz.message.domain.dto.DiseaseConsultationSaveDTO;
import com.qingfeng.medical.biz.message.domain.entity.DiseaseConsultation;
import com.qingfeng.medical.biz.message.service.DiseaseConsultationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 病情咨询表
 *
 * @author 清风学Java
 * @date 2023-04-14 14:47:16
 */
@Api(tags = "病情咨询表管理")
@RestController
@RequestMapping("/api/msg/diseaseConsultation")
@Validated
public class DiseaseConsultationApiController extends BaseController {

    @Autowired
    private DiseaseConsultationService diseaseConsultationService;
    @Autowired
    private UserInfoService userInfoService;

    @ApiOperation(value = "根据科室门诊Id查询医师信息", notes = "根据科室门诊Id查询医师信息")
    @GetMapping("/doctor/list/{depId}")
    @Log(title = "病情咨询管理", businessType = BusinessType.SELECT, message = "根据科室门诊Id查询医师信息")
    public Result<List<DiseaseDoctorVo>> doctorList(@PathVariable("depId") Long depId){
        List<DiseaseDoctorVo> diseaseDoctorList = diseaseConsultationService.doctorList(depId);
        return Result.ok(diseaseDoctorList);
    }

    @ApiOperation(value = "根据用户Id查询用户信息", notes = "根据用户Id查询用户信息")
    @GetMapping("/user/info/{userId}")
    @Log(title = "病情咨询管理", businessType = BusinessType.SELECT, message = "根据用户Id查询用户信息")
    public Result<UserInfo> userInfo(@PathVariable("userId") Long userId){
        return Result.ok(userInfoService.getById(userId));
    }

    @ApiOperation(value = "保存病情咨询表信息", notes = "保存病情咨询表信息")
    @PostMapping
    @Log(title = "病情咨询管理", businessType = BusinessType.INSERT, message = "保存病情咨询表信息")
    public Result save(@RequestBody @Validated DiseaseConsultationSaveDTO diseaseConsultationSaveDTO){
		diseaseConsultationService.saveDiseaseConsultation(diseaseConsultationSaveDTO);
        return Result.ok();
    }

    @ApiOperation(value = "根据用户Id和医生Id查询咨询信息", notes = "根据用户Id和医生Id查询咨询信息")
    @GetMapping("/disease/list/{userId}/{doctorId}")
    @Log(title = "病情咨询管理", businessType = BusinessType.SELECT, message = "根据用户Id和医生Id查询咨询信息")
    public Result<List<DiseaseConsultation>> diseaseList(
            @PathVariable("userId") Long userId,
            @PathVariable("doctorId") Long doctorId){
        List<DiseaseConsultation> diseaseConsultationList = diseaseConsultationService.diseaseList(userId, doctorId);
        return Result.ok(diseaseConsultationList);
    }
}
